<template>
	<view>测试</view>
</template>

<script setup>
// const clickHandle = () => {
// 	uni.connectSocket({
// 		url: 'ws://sock.niushijuejin.cn/Hubs?id=2l34jl23j4l1j23lk1j23',
// 		method: 'GET',
// 		success: function() {
// 			console.log("连接成功")
// 		},
// 		fail: function() {
// 			console.log("连接失败")
// 		}
// 	});
	
	
// }

import { ref,onMounted,onUnmounted } from 'vue'
import WebsocketUtil from '@/common/websocket.ts'
const websocket = ref(null); 

// 组件挂载时初始化WebSocket  
onMounted(() => {  
  websocket.value = new WebsocketUtil('wss://sock.niushijuejin.cn/Hubs', 5);  
  
  // 可以注册消息回调  
  websocket.value.onMessage(data => {  
    console.log('Received data:', data);  
  });  
});  
  
// 组件卸载时清理WebSocket  
onUnmounted(() => {  
  if (websocket.value) {  
    websocket.value.destroy();  
  }  
}); 

</script>

<style>
</style>